package com.qn.servicelocator.old;

import com.qn.servicelocator.ContentType;
import com.qn.servicelocator.Parser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;

@Service
public class OldClient {
    private final Parser csvParser;
    private final Parser jsonParser;

    @Autowired
    public OldClient(@Qualifier("CSVParser") Parser csvParser, @Qualifier("JSONParser") Parser jsonParser) {
        this.csvParser = csvParser;
        this.jsonParser = jsonParser;
    }

    public String getAll(ContentType contentType) {
        switch (contentType) {
            case CSV:
                return csvParser.parse();
            case JSON:
                return jsonParser.parse();
            default:
                return "暂不支持该类型解析";
        }
    }
}